using UnityEngine.Serialization;

namespace DA.AnimGraph {
    public enum ConditionType : byte {
        ExitTime = 1,
        Blackboard
    }

    public enum ConditionParameterType : byte {
        Float,
        Int,
        // Bool,
    }

    public enum CompareOperator : byte {
        Equal,
        NotEqual,
        Greater,
        GreaterOrEqual,
        Less,
        LessOrEqual,
        True,
        False,
    }


    public struct TransitionDesc {
        public int sourceState; // -1代表任意状态
        public int targetState;
        public float duration;
        public TransitionConditionDesc[] conditions;

        public TransitionDesc(int source, int target, float duration) {
            sourceState = source;
            targetState = target;
            this.duration = duration;
            conditions = null;
        }
    }


    public struct TransitionConditionDesc {
        public ConditionType conditionType;
        public float exitTime;
        public ConditionCompareDesc compare;

        public TransitionConditionDesc(float exitTime) {
            this.exitTime = exitTime;
            conditionType = ConditionType.ExitTime;
            compare = default;
        }
        public TransitionConditionDesc(ConditionCompareDesc compare) {
            this.compare = compare;
            exitTime = 0;
            conditionType = ConditionType.Blackboard;
        }
    }


    public struct ConditionCompareDesc {
        public AUID paramKey;
        public AUID compareParamKey;
        public Number compareValue;
        public ConditionParameterType paramType;
        public CompareOperator compareOperator;

        public ConditionCompareDesc(AUID paramKey, AUID compareParamKey, ConditionParameterType paramType, CompareOperator compareOperator) {
            this.paramKey = paramKey;
            this.compareParamKey = compareParamKey;
            this.paramType = paramType;
            this.compareOperator = compareOperator;
            this.compareValue = default;
        }
        public ConditionCompareDesc(AUID paramKey, int compareValue, ConditionParameterType paramType, CompareOperator compareOperator) {
            this.paramKey = paramKey;
            this.compareParamKey = 0;
            this.paramType = paramType;
            this.compareOperator = compareOperator;
            this.compareValue = default;
            this.compareValue.intValue = compareValue;
        }
        public ConditionCompareDesc(AUID paramKey, float compareValue, ConditionParameterType paramType, CompareOperator compareOperator) {
            this.paramKey = paramKey;
            this.compareParamKey = 0;
            this.paramType = paramType;
            this.compareOperator = compareOperator;
            this.compareValue = default;
            this.compareValue.floatValue = compareValue;
        }
    }

}
